<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src 'self'; script-src 'none'; style-src 'self'; object-src 'none'; font-src 'none'; form-action 'self'; frame-src 'none'; media-src 'none'; manifest-src 'none'; worker-src 'none';">
    <title>裁判文书网</title>
    <link rel="stylesheet" href="/style.css">
</head>
<body>
    <header class="search-header">
        <nav class="search-nav">
            <a href="/"><img src="/logo.png"></a>
            <form id="search" action="/" method="get">
                <div class="searchbar search-searchbar">
                    <input class="search-input" type="text" id="search" name="search" value="{{ search }}">
                </div>
            </form>
        </nav>
        <nav class="search-second-nav">
            <div>
                {% match search_type.as_str() %}{% when "legal_basis" %}
                <a href="/?search={{search}}&search_type=default">搜索</a>
                <a href="/?search={{search}}&search_type=legal_basis" class="selected">法律依据</a>
                <a href="/?search={{search}}&search_type=cause">案由</a>
                {% if enable_full_text %}
                <a href="/?search={{search}}&search_type=full_text">全文</a>
                {% endif %}
                {% when "cause" %}
                <a href="/?search={{search}}&search_type=default">搜索</a>
                <a href="/?search={{search}}&search_type=legal_basis">法律依据</a>
                <a href="/?search={{search}}&search_type=cause" class="selected">案由</a>
                {% if enable_full_text %}
                <a href="/?search={{search}}&search_type=full_text">全文</a>
                {% endif %}
                {% when "full_text" %}
                <a href="/?search={{search}}&search_type=default">搜索</a>
                <a href="/?search={{search}}&search_type=legal_basis">法律依据</a>
                <a href="/?search={{search}}&search_type=cause">案由</a>
                {% if enable_full_text %}
                <a href="/?search={{search}}&search_type=full_text" class="selected">全文</a>
                {% endif %}
                {% else %}
                <a href="/?search={{search}}&search_type=default" class="selected">搜索</a>
                <a href="/?search={{search}}&search_type=legal_basis">法律依据</a>
                <a href="/?search={{search}}&search_type=cause">案由</a>
                {% if enable_full_text %}
                <a href="/?search={{search}}&search_type=full_text">全文</a>
                {% endif %}
                {% endmatch %}
            </div>
            <div>
                共找到 {{ total }} 条结果
            </div>
        </nav>
    </header>

    <main class="search-results">
        {% for (id,case) in cases %}
        <div class="search-result-text">
            <a class="nounderline" href="/case/{{id}}" target="_blank">
                <h3 class="underlineonhover">{{ case.case_name }}</h3>
            </a>
            <p>{{ case.judgment_date }} - {{ case.case_type }} - {{ case.procedure }}</p>
            <p>{{ case.full_text|truncate(240) }}</p>
            <a class="nounderline" href="/case/{{id}}" target="_blank">{{case.case_id}} - {{ case.court }}</a>
        </div>
        {% endfor %}
    </main>

    <div class="pagination">
        {% if cases.len() >= 20 %}
            {% if offset >= 20 %}
            <a href="/?search={{ search }}&offset={{ offset - 20 }}">上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
            {% endif %}
        <a href="/?search={{ search }}&offset={{ offset + 20 }}">下一页</a>
        {% endif %}
    </div>
</body>
</html> 